import requests
import json

# 设置 RabbitMQ API 的认证和地址
auth = ("cloud", "7#BD2CFc3TBV}7m7z")
url = "http://10.5.1.47:15672/api/"

# 获取所有交换机
exchanges = requests.get(url + "exchanges", auth=auth).json()

# 获取所有绑定
bindings = requests.get(url + "bindings", auth=auth).json()

# 找出没有队列绑定的交换机
unbound_exchanges = [
    ex["name"] for ex in exchanges if all(b["source"] != ex["name"] for b in bindings)
]

print("Unbound Exchanges:", unbound_exchanges)
